<template>
	<view class="menus">
		<swiper class="swiper u-border-bottom" indicator-dots="true" indicator-color="#efefef"
			indicator-active-color="#dddddd">
			<swiper-item v-for="(page,pagesize) in resList">
				<view class="menu">
					<p v-for="(item,index) in specialList.slice(pagesize*sec,8*(pagesize+1))" @click="goIndex(item)">
						<image :src="item.specialIcon" mode="aspectFit"></image>
						<span class="u-line-1 titlesss">{{item.specialName}}</span>
					</p>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		props: {
			specialList: {
				type: Array,
				default: false
			}
		},
		data() {
			return {
				fir:0,
				sec:8
			};
		},
		onShow() {
			console.log(specialList)
		},
		computed: {
			resList: function() {
				const specialList = this.specialList
				return (specialList.length / 8) > parseInt(specialList.length / 8) ? parseInt(specialList.length / 8) +
					1 : (specialList.length / 8)
			}
		},
		methods: {
			goIndex(item) {
				uni.navigateTo({
					url: `/pages/main/child/classAllList?obj=${encodeURIComponent(JSON.stringify(item))}`
				});
			}
		}
	}
</script>

<style lang="scss">
	.swiper {
		height: 170px;
	}

	.menus {
		position: fixed;
		left: 0px;
		top: -10px;
		width: 100%;
		background-color: #FFFFFF;
	}

	.menu {
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		grid-template-rows: repeat(2, 1fr);
		grid-gap: 10rpx 20rpx;
		height: 310rpx;
		padding: 20rpx;

		p {
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 68rpx;
				height: 68rpx;
			}

			span {
				font-size: 26rpx;
				font-weight: normal;
				color: #2C2C2C;
				margin-top: 20rpx;
			}
		}
		.titlesss{
		width: 150rpx;
		text-align: center;
		}
	}
</style>
